function PageOptions(form, state) {
  var that = this;
  this.form = $(form);
  this.state = state;

  var mapOpt = this.form.find('.containeroptions').change(function() {
    that.update($(this), 'map');
  });
  this.update(mapOpt, 'map');

  var miscOpt = this.form.find('.miscoptions').change(function() {
    that.update($(this), 'misc');
  });
  this.update(miscOpt, 'misc');
}

PageOptions.prototype.update = function(form, ns) {
  var state = this.state;
  form.find('input').each(function() {
    var input = $(this),
        val = input.val();
    if (input.attr('type') == 'checkbox') {
      val = input.attr('checked');
    }
    var name = input.attr('name');
    state[ns][name] = val;
  });
};
